package com.theima.socket.socketdemo3;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;

/**
 * @program: Myset
 * @description:
 * @author: xuejingjing
 * @create: 2021-06-24 23:41
 **/
public class ServerDemo {
    public static void main(String[] args) throws IOException {
        //10000端口接受
        DatagramSocket  ds = new DatagramSocket(10000);

        while (true) {
            byte [] bytes = new byte[1024];
            DatagramPacket dp = new DatagramPacket(bytes,bytes.length);

            ds.receive(dp);

            byte[] data = dp.getData();

            int length = dp.getLength();


            System.out.println(new String(data,0,length));
        }

       // ds.close();


    }
}
